package com.zhaopin.valatile;

/**
 * @author Administrator
 * @create 2021-02-26 11:39
 */
public class VolatileMain {

    private final static int TOTAL_THREADS = 2;

    public static void main(String[] args) throws InterruptedException {
        VolatileData volatileData = new VolatileData();

        Thread[] threads = new Thread[TOTAL_THREADS];
        for (int i = 0; i < TOTAL_THREADS; ++i) {
            threads[i] = new VolatileThread(volatileData);
        }


        //开始读取变量值的操作
        for (int i = 0; i < TOTAL_THREADS; ++i) {
            threads[i].start();
        }


        //等待所有线程操作终止
        for (int i = 0; i < TOTAL_THREADS; ++i) {
            threads[i].join();
        }

    }
}
